package com.pet.cloud.console.api.handler.command.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.pet.cloud.console.api.handler.command.TenantCommandHandler;
import com.pet.cloud.console.api.param.TenantSaveParam;
import com.pet.cloud.console.api.view.TenantSettledView;
import com.pet.cloud.console.infrastructure.entity.TenantInfo;
import com.pet.cloud.console.infrastructure.service.PermissionInfoService;
import com.pet.cloud.console.infrastructure.service.TenantInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class TenantCommandHandlerImpl implements TenantCommandHandler {

    @Resource
    private TenantInfoService tenantInfoService;

    @Resource
    private PermissionInfoService permissionInfoService;


    @Override
    public TenantSettledView tenantSettled(TenantSaveParam param) {

        // 获取租户编号
        String tenantId = this.getTenantId();


        // 保存租户信息
        tenantInfoService.save(this.buildTenantInfo(param, tenantId));

        return TenantSettledView.build(tenantId);
    }


    private TenantInfo buildTenantInfo(TenantSaveParam param, String tenantId) {
        TenantInfo result = new TenantInfo();
        result.setTenantId(tenantId);
        return result;
    }

    private String getTenantId() {
        return "";
    }

}
